package com.beidu.lottery.call.result;

import com.beidu.lottery.call.errorcode.CommonCode;
import lombok.Getter;

/**
 * 自定义异常
 */
@Getter
public class ResException extends RuntimeException {

    /**
     * 错误类型码
     */
    private String code;

    /**
     * 错误类型描述信息
     */
    private String msg;

    public ResException(String msg) {
//        super(CommonCode.findByCode(code).msg());
//        super(CommonCode.findByCode(code).name());
        this.code = "500";
        this.msg = msg;
    }

    public ResException(String code, StringBuilder msg) {
        super(msg.insert(0, CommonCode.findByCode(code).getMsg()).toString());
        this.code = code;
        this.msg = msg.toString();
    }

    public ResException(String code, String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
    }

    public ResException(CommonCode commonCode) {
        super(commonCode.getMsg());
        this.code = commonCode.getCode();
        this.msg = commonCode.getMsg();
    }

    public String code() {
        return this.code;
    }

    public String msg() {
        return this.msg;
    }

}
